package com.tuanzi.loan.web.bean.settlement;

import com.tuanzi.loan.business.entity.family.ProductInfo;
import com.tuanzi.loan.business.entity.settlement.CompanyInfo;
import com.tuanzi.loan.business.service.family.ProductInfoService;
import com.tuanzi.loan.business.service.settlement.CompanyInfoService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.vo.request.settlement.SettlementUvReportRequest;
import com.tuanzi.loan.vo.response.settlement.SettlementUvReportResponse;
import com.tuanzi.loan.web.configuration.JSFListingBean;
import com.tuanzi.loan.web.lazy.settlement.SettlementUvReportLazyDataModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.faces.bean.ViewScoped;
import java.util.List;

/**
 * @author caiwanlin
 * @create 2018-03-27 15:06
 */
@Data
@Debug
@Component
@ViewScoped
@EqualsAndHashCode(callSuper = true)
public class SettlementUvReportBean extends JSFListingBean<SettlementUvReportRequest,SettlementUvReportResponse> {
    private List<ProductInfo> productInfoList;
    private List<CompanyInfo> companyInfoList;
    @Autowired
    private ProductInfoService productInfoService;
    @Autowired
    private CompanyInfoService companyInfoService;
    @PostConstruct
    private void init() {
        initLazyDataModel();
    }

    public void onReset(){
        initLazyDataModel();
    }
    private void initLazyDataModel() {
        $ = new SettlementUvReportRequest();
        $.setIsGroup(1);
        productInfoList = productInfoService.listAllProductInfo();
        companyInfoList = companyInfoService.findAllCompanyName();
        lazyDataModel = new SettlementUvReportLazyDataModel($);
    }
}
